
	/**
	 * Console Stub
	**/	
	if( typeof(console) == "undefined" ) {
		
		console = {
			
			log: function() {
			}
			
		};
		
	};
	
	Ext.namespace("panel.console");
	
	panel.console.shift = 0;
	
	panel.console.log = function() {
		
		/* {% if $environment.state == "local" %} */
		
		if( arguments[arguments.length-1] == "<<<" ) {
			
			panel.console.shift--;
			if( panel.console.shift < 0 ) { panel.console.shift = 0; } 
			console.log("-------------------------");
			
		}	// if
		
		var shift = String.leftPad("", panel.console.shift, "\t");
		
		console.log(shift, arguments);
		
		if( arguments[arguments.length-1] == ">>>" ) {
			
			panel.console.shift++;
			if( panel.console.shift > 5 ) { panel.console.shift = 5; }
			console.log("-------------------------");
			
		}	// if
		
		/* {% /if %} */
		
	};
	
	panel.console.time = {
		
		timers: {},
		delta: 0,
		
		log: function(key, v) {
			
			/* {% if $environment.state == "local" %} */
			
			if( panel.console.time.timers[key] == undefined ) {
			
				console.log("[:] ", key, "- 0ms ", v ? v : "");	
				panel.console.time.timers[key] = new Date().getTime();
				
			} else {
				
				var delta = new Date().getTime() - panel.console.time.timers[key];
				console.log("[:] ", key, "-", delta.toString() + "ms ", v ? v : " ");		
				
			}	// if
			
			panel.console.time.delta = delta || 0;
			return panel.console.time.delta;
			
			/* {% /if %} */
						
		},
		
		clear: function(key) {
			
			delete panel.console.time.timers[key];
			
		}
		
	};
	
	panel.console.logDomElements = function(extended) {
		
		panel.console.log(
			"DOM ELEMENTS:", 
			document.getElementsByTagName('*').length
		);
		
		if( extended ) {
		
			var elements = [
				"div", "table", "tbody", "td", "tr", "span", "img", "a", "b", "i", "font"
			];	
			
			elements.each( function(e) {
				
				var x = { elements: document.getElementsByTagName(e) };
				
				panel.console.log(
					"DOM ELEMENTS [" + e + "]:", 
					document.getElementsByTagName(e).length,
					x
				);
				
			});
			
		}
		
	};
	
	panel.console.logEvents = function() {

		Ext.util.Observable.prototype.fireEvent =
		Ext.util.Observable.prototype.fireEvent.createInterceptor( function(event) {
			
			panel.console.time.log("event", [this, "fired -> ", event]);
			
		});
			
		Ext.util.Observable.prototype.fireEvent = 
		Ext.util.Observable.prototype.fireEvent.createSequence( function(event) { 
			
			panel.console.time.log("event", [this, "fired <- ", event]); 
			
		} );
		
	};
